<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>仪表盘</title>
    <script type="text/javascript" src="https://fastly.jsdelivr.net/npm/echarts@5.3.3/dist/echarts.min.js"></script>
  </head>
  <body>
    <div id="main"></div>
    <script>
      var chartDom = document.getElementById("main");
      const width = document.body.clientWidth;
      chartDom.style.width = width + "px";
      chartDom.style.height = width + "px";
      const fontSize = width / 30;
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        series: [
          {
            type: "gauge",
            axisLine: {
              lineStyle: {
                width: 20,
                color: [
                  [0.3, "#67e0e3"],
                  [0.7, "#37a2da"],
                  [1, "#fd666d"],
                ],
              },
            },
            pointer: {
              itemStyle: {
                color: "auto",
              },
            },
            axisTick: {
              distance: -10,
              length: 8,
              lineStyle: {
                color: "#fff",
                width: 2,
              },
            },
            splitLine: {
              distance: -20,
              length: 20,
              lineStyle: {
                color: "#fff",
                width: 4,
              },
            },
            axisLabel: {
              color: "auto",
              distance: 40,
              fontSize: 15,
            },
            detail: {
              valueAnimation: true,
              formatter: "{value} km/h",
              color: "auto",
              fontSize
            },
            data: [
              {
                value: 70,
              },
            ],
          },
        ],
      };
      setInterval(function () {
        myChart.setOption({
          series: [
            {
              data: [
                {
                  value: +(Math.random() * 100).toFixed(2),
                },
              ],
            },
          ],
        });
      }, 2000);

      option && myChart.setOption(option);
    </script>
  </body>
</html>
